﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Order;
using System.Windows.Forms;

namespace OrderWindow
{
    public partial class Form3 : Form
    {
        private OrderDetail neworderdetail = new OrderDetail();
        private List<OrderDetail> items = new List<OrderDetail>();
        public Order.Order UpdateOrder
        {
            get { return new Order.Order(Convert.ToInt32(label7.Text), textBox5.Text, items); }
        }
        public Form3(Order.Order order)
        {
            InitializeComponent();
            label7.Text =Convert.ToString(order.OrderID);
            textBox5.DataBindings.Add("Text", order, "CustomerID");
            textBox1.DataBindings.Add("Text", neworderdetail, "OrderdetailID");
            textBox2.DataBindings.Add("Text", neworderdetail, "ProductID");
            textBox3.DataBindings.Add("Text", neworderdetail, "ProductNumber");
            textBox4.DataBindings.Add("Text", neworderdetail, "Value");
            bindingSource1.DataSource = order;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OrderDetail myclone = new OrderDetail(neworderdetail.OrderdetailID, neworderdetail.ProductID, neworderdetail.ProductNumber, neworderdetail.Value);
            bindingSource1.Remove(bindingSource1.Current);
            bindingSource1.Add(myclone);
            items.Add(myclone);
            textBox1.Clear();
            textBox3.Clear();
            textBox4.Clear();
            textBox2.Clear();
            bindingSource1.ResetBindings(false);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
